<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" session="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<br>
<a href="/">Home</a> &nbsp; <a href="/dispatch/buy">Buy</a>
<br>
<table width="100%">
<tr>
	<td>Purchased Date</td>
	<td>Symbol</td>
	<td>Purchased Price</td>
	<td>Market Price</td>
	<td>Shares</td>
	<td>Change</td>
	<td>Percent Change</td>
	<td>Gain Today</td>
	<td>Unrealized</td>
	<td>Paid Amount</td>
	<td>Market Value</td>
    <td>Actions</td>
</tr>

<c:set var="gainToday" value="0"/>

<c:forEach var="position" items="${positionList}">
<c:set var="gainToday" value="${gainToday + position.gainToday}"/>
<tr>
	<td><fmt:formatDate value="${position.date}" pattern="MM/dd/yyyy"/></td>
	<td><c:out value="${position.symbol}"/></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.purchasedPrice}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.last}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="0" maxFractionDigits="0" value="${position.volume}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.change}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.percentChange}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.gainToday}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.unrealized}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.paid}" /></td>
	<td><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${position.marketValue}" /></td>
    <td><a href='/dispatch/delete?id=<c:out value="${position.id}"/>'>delete</a> &nbsp;
        <a href='/dispatch/sell?id=<c:out value="${position.id}"/>'>sell</a> &nbsp;
        <a href='/dispatch/update?id=<c:out value="${position.id}"/>'>update</a> &nbsp;
    </td>

</tr>
</c:forEach>
</table>

Total gain today: <fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${gainToday}" />
<br>
<a href="/">Home</a> &nbsp; <a href="/dispatch/buy">Buy</a>
</body>
</html>